package collection;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * 删除集合中存在的b
 */

public class Demo04 {
  public static void main(String[] args) {
    ArrayList<String> list = new ArrayList<>();
    list.add("a");
    list.add("b");
    list.add("b");
    list.add("c");
    list.add("d");

    Iterator<String> it = list.iterator();
    while (it.hasNext()) {
      String s = it.next();
      if ("b".equals(s)) {
        it.remove();
      }
    }
  }
}
